package com.example.mobile2121606109ycg0329homework;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private ImageView ivMainFS;
    private Button btnMainSwh;
    private int i;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        btnMainSwh.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                i++;
                if (i == 1){
                    ivMainFS.setImageResource(R.drawable.off);
                }else if (i == 2){
                    ivMainFS.setImageResource(R.drawable.on);
                }else {
                    i = 0;
                }
            }
        });
    }

    private void initView() {
        ivMainFS = (ImageView) findViewById(R.id.ivMainFS);
        btnMainSwh = (Button) findViewById(R.id.btnMainSwh);
    }
}